package cn.sytton.taffecloud.serivce.auth.controller;

import cn.sytton.taffecloud.common.base.doc.Api;
import cn.sytton.taffecloud.common.base.doc.ApiOperation;
import cn.sytton.taffecloud.serivce.auth.security.sms.code.SmsCode;
import cn.sytton.taffecloud.serivce.auth.security.sms.code.SmsCodeFactory;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 短信验证码控制层
 *
 * @author skyrock
 */
@Api(tags = "短信验证码")
@RestController
@RequestMapping("/sms")
public class SmsController {

    @Resource
    private SmsCodeFactory smsCodeFactory;

    @ApiOperation("获取短信验证码")
    @PostMapping("/code")
    public void sendCode(@RequestBody SmsCode smsCode) {
        smsCodeFactory.createAndSend(smsCode.getCellphone());
    }
}
